<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>商品管理</title>
    <link th:href="@{/css/bootstrap.css}" rel="stylesheet">
    <link th:href="@{/css/zTreeStyle.css}" rel="stylesheet">
    <link th:href="@{/css/public.css}" rel="stylesheet">
    <link th:href="@{/css/ymPrompt.css}" rel="stylesheet">
</head>
<body>

<div class="container-fluid">
<!--    <input type="hidden" id="pageNum" th:value="${pageNum}"/>-->
    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
        <tbody>
        <tr>
            <td>
                <table width="100%" border="0" cellspacing="6" cellpadding="0"
                       style="border-collapse: separate; border-spacing: 6px;">
                    <tr valign="top">
                        <td>
                            <table width="100%" border="0" cellspacing="0" cellpadding="6" class="blockTable">
                                <tr>
                                    <td valign="middle" class="blockTd">
                                        <img src="http://javen666.com:8080/fxmall/Framework/Icons/icon012a6.gif"/>
                                        商品信息列表
                                    </td>
                                </tr>
                                <tr>
                                    <td style="padding: 0 8px 4px;">
                                        <a href='javascript:void(0);' class='zPushBtn' tabindex='-1' onClick="add()">
                                            <img th:src="@{/img/icon003a2.gif}"/><b>新增&nbsp;</b>
                                        </a>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="padding-top: 0px; padding-left: 6px; padding-right: 6px; padding-bottom: 8px;">
                                        <table width="100%" cellpadding="2" cellspacing="1"
                                               class="dataTable" sortstring="" id="dg1" page="true" size="0"
                                               multiselect="true" autofill="true" scroll="false" lazy="false"
                                               cachesize="0">
                                            <tr ztype="head" class="dataTableHead">
                                                <td width="5%" align="center">
                                                    序 号
                                                </td>
                                                <td align="center" width="15%">
                                                    <b>商品名称</b>
                                                </td>
<!--                                                <td align="center" width="15%">-->
<!--                                                    <b>商品图片</b>-->
<!--                                                </td>-->
                                                <td align="center" width="10%">
                                                    <b>状态</b>
                                                </td>
                                                <td align="center" width="10%">
                                                    <b>上/下架</b>
                                                </td>
                                                <td align="center" width="10%">
                                                    <b>秒杀</b>
                                                </td>
                                                <td align="center" width="12%">
                                                    <b>操作</b>
                                                </td>
                                            </tr>
                                            <tr th:each="g,var : ${goodsList}" height="35" style="background:#ffffff">
                                                <td align="center" th:text="${var.count}">
                                                </td>
                                                <td align="center" th:text="${g.name}">
                                                </td>
<!--                                                <td align="center" height="100px">-->
<!--                                                    <img th:src="${g.pic}" style="width:150px;height:100px;"/>-->
<!--                                                </td>-->
                                                <td align="center">
                                                    <span style="color:blue" th:if="${g.status==0}">待上架</span>
                                                    <span style="color:green" th:if="${g.status==1}">已上架</span>
                                                </td>
                                                <td align="center">
                                                    <a href='javascript:void(0);' class='zPushBtn'
                                                       onClick="up(this)" th:data="${g.id}">
                                                        <img th:src="@{/img/icon003a4.gif}"><b>上架&nbsp;</b>
                                                    </a>
                                                    <a href='javascript:void(0);' class='zPushBtn'
                                                       onClick="down(this)" th:data="${g.id}">
                                                        <img th:src="@{/img/icon003a3.gif}"><b>下架&nbsp;</b>
                                                    </a>
                                                </td>

                                                <td align="center">
                                                    <a href='javascript:void(0);' class='zPushBtn'
                                                       onClick="secKill(this)" th:data="${g.id}">
                                                        <span style="color:blue" th:if="${g.isSeckill==0}">加入秒杀</span>
                                                        <span style="color:green" th:if="${g.isSeckill==1}">正在秒杀</span>
                                                    </a>
                                                </td>

                                                <td align="center">
                                                    <a href='javascript:void(0);' class='zPushBtn'
                                                       onClick="edit(this)" th:data="${g.id}">
                                                        <img th:src="@{/img/icon003a4.gif}"><b>修改&nbsp;</b>
                                                    </a>
                                                    <a href='javascript:void(0);' class='zPushBtn'
                                                       onClick="del(this)" th:data="${g.id}">
                                                        <img th:src="@{/img/icon003a3.gif}"><b>删除&nbsp;</b>
                                                    </a>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="10" align="center" id="dg1_PageBar" class="pagebg">
                                                    <div style='float: right; font-family: Tahoma;' class="flickr">
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>


                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        </tbody>
    </table>

<!--    <span th:each="page:${pageList}">-->
<!--        <a href="javascript:void(0)" onclick="page(this)" th:text="${page}"></a>&nbsp;&nbsp;-->
<!--    </span>-->

</div>

<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/js/bootstrap.js}"></script>
<script th:src="@{/js/ymPrompt.js}"></script>
<script th:src="@{/js/public.js}"></script>
<script th:src="@{/js/ServerClock.js}"></script>
<script th:src="@{/js/table.js}"></script>

<script type="text/javascript" th:inline="javascript">
    // /*<![CDATA[*/
    // var base = /*[[@{/}]]*/ ''; //获取context-path
    // /*]]>*/
    // var url = "";

    function reload(address){
        if(address == null){
            address = url;
        }
        // $("#right").load(address);
        // $(".modal-backdrop").remove();
        window.location.href =address;
    }

    function post(url , jsonData , success , error){
        $.post(url ,
            jsonData,
            function(data){
                console.log(data);
                if (data.success){ //business logic is success
                    if (success) success(data);  //callback
                } else{ //business logic is error
                    if (error) error(data); else alert(data.error);
                }
            });
    }

</script>

<script type="text/javascript">




    function add(source) {
        reload("add");
    }

    function up(source) {
        var id = $(source).attr("data");
        post("up", {"id": id}, function (data) {
            reload("list");
        });
    }

    function down(source) {
        var id = $(source).attr("data");
        post("down", {"id": id}, function (data) {
            reload("list");
        });
    }

    function secKill(source){
        var id = $(source).attr("data");
        post("secKill" , {"id" : id} , function(data){
            reload("list");
        });
    }

    function edit(source) {
        var id = $(source).attr("data");
        reload("add?id=" + id);
    }

    function del(source) {
        var id = $(source).attr("data");
        post("del", {"id": id}, function (data) {
            reload("list");
        });
    }
</script>

</body>
</html>